<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<html>
<head>
		<meta charset="utf-8">
		<title>注册界面</title>
		<link rel="stylesheet" href="${path}/statics/css/member/login/reset.css" />
		<link rel="stylesheet" href="${path}/statics/css/member/login/common.css" />
		<link rel="stylesheet" href="${path}/statics/layui/css/layui.css">
		
	</head>
	<body>
		<div class="wrap login_wrap">
			<div class="content">
				
				<div class="logo"></div>
				
				<div class="login_box">	
					
					<div class="login_form" style="padding-bottom:30px">
						<div class="login_title">
							注册
						</div>
						<form action="" id="formId" method="post">
							
							<div class="form_text_ipt">
								<input name="nickName" id="nickNameId" type="text" lay-verify="required" placeholder="昵称">
							</div>
							<div class="ececk_warning"><span>昵称不能为空</span></div>
							<div class="form_text_ipt">
								<input name="mobile" id="mobileId" type="text" lay-verify="required|phone" placeholder="手机号">
							</div>
							<div class="ececk_warning"><span>手机号不能为空</span></div>
							<div class="form_text_ipt">
								<input name="password" id="pwdId" type="password" placeholder="密码">
							</div>
							<div class="ececk_warning"><span>密码不能为空</span></div>
							<div class="form_text_ipt">
								<input name="repassword" id="repwdId" type="password" placeholder="确认密码">
							</div>
							<div class="ececk_warning"><span>密码不能为空</span></div>
						
							<div class="form_btn">
								<button type="button" id="saveBtn" onclick="javascript:window.location.href='#'">注册</button>
							</div>
							<div class="form_reg_btn">
								<span>已有帐号？</span><a href="/frontCtl/toLogin">马上登录</a>
							</div>
						</form>
					</div>
				</div>
			</div>
		</div>
		
		<script type="text/javascript" src="${path}/statics/js/jquery-1.8.3.js"></script>
		<script src="${path}/statics/layui/layui.js"></script>
		<script type="text/javascript">
			layui.use(['jquery','layer'], function(){
		
			  var $ = layui.jquery;
			  var layer = layui.layer;
			
			       
			  
			  //给登录按钮绑定事件
			  $("#saveBtn").click(function(){
				var nickName = $("#nickNameId").val();
			  	var mobile = $("#mobileId").val();
			  	var pwd = $("#pwdId").val();
				var repwd = $("#repwdId").val();
			  	
				
				
			  	if(mobile.length == 0){
			  		layer.msg("手机号不能为空",{icon:2 , time:1000});
					return;
			  	}
				if(!(/^1[3456789]\d{9}$/.test(mobile))){
					layer.msg("手机号格式错误",{icon:2 , time:1000});
				  return;
				}
				if(pwd.length == 0){
					layer.msg("密码不能为空",{icon:2 , time:1000});
					return;
				}
				if(repwd.length == 0){
					layer.msg("确认密码不能为空",{icon:2 , time:1000});
					return;
				}
				if(repwd != pwd){
					layer.msg("两次密码不一样!",{icon:2 , time:2000});
					return;
				}
				
				
				$.post("${path}/frontCtl/register",{nickName:nickName,mobile:mobile,pwd:pwd},function(res){
					if(res == 0){
						layer.msg("注册成功,即将跳转到登录界面",{icon:1 , time:2000},function(){
							location.replace("${path}/frontCtl/toLogin");
						});
						
					}else if(res == 2){
						layer.msg("该手机号已经注册,请直接登录!",{icon:5 , time:2000});
					}else{
						layer.msg("系统繁忙,请稍后!",{icon:5 , time:1000});
					}
				});
			  }) 
			});
		
		</script>	

	</body>
</html>
